<?php

/**
 * Description of apiAction
 *
 * @author dro
 */
class AbstractAction {

	//properties
	protected $page;
    protected $minScript;
    protected $rootPath;
    protected $staticPath;
    protected $version;

	//getter / setter
	public function getPage() {
		return $this->page;
	}

	public function __construct() {
		if (isset($_GET[VIEW_PARAM]))
			$this->page = $_GET[VIEW_PARAM];
		else if (isset($_GET[METHOD_PARAM]))
			$this->page = $_GET[METHOD_PARAM];
		if (isset($_GET[FIELDS_PARAM]))
			$this->fields = $_GET[FIELDS_PARAM];
		if (isset($_GET[ID_PARAM]))
			$this->id = $_GET[ID_PARAM];
		$this->minScript = MIN_SCRIPT;
        $this->rootPath = ROOT_PATH;
        $this->staticPath = STATIC_PATH;
        $this->jsStaticPath = JS_STATIC_PATH;
        $this->version = VERSION_NUMBER;
	}
	
	protected function renderError(){
		if($this->isError()){
			include(ERROR_ROOT . 'error'.$this->page.'.php');
			$this->renderFooter();
			die();
		}
	}
	
	protected function isError(){
		return in_array($this->page, array('400', '401', '403', '404', '500'));
	}

	protected function renderFooter() {
		$pageAction = $this;
		include(VIEW_ROOT . 'footer.php');
	}
	
	public function search(){
		/*if (isset($_GET['q'])) {
			include MDL_ROOT . 'experience.php';
			include MDL_ROOT . 'education.php';
			include MDL_ROOT . 'skillFamily.php';
			include MDL_ROOT . 'skillGroup.php';
			include MDL_ROOT . 'skill.php';
			include MDL_ROOT . 'interest.php';
			include MDL_ROOT . 'travel.php';
			include MDL_ROOT . 'search.php';
			include CTRL_ROOT . 'searchAction.php';
			include VIEW_ROOT . 'search.php';
		}*/
	}

	public function loadMdl($section, $mdlArr = null) {
		if ($mdlArr != null)
			foreach ($mdlArr as $mdl)
				include( MDL_ROOT . $mdl . '.php');
		
		@include (MDL_ROOT . $section . '.php');
	}

}

?>
